<template>
    <div class="collectBox">
        <Myhead :title="title"></Myhead>
        <van-cell-group v-show="flat">
            <van-cell @click="pathGo(item)" center v-for="item in collectList.list" :title="item.title" value="已收藏" />
            <!-- <van-cell title="落叶的位置" value="已关注" />
            <van-cell title="落叶的位置" value="已关注" />
            <van-cell title="落叶的位置" value="已关注" />
            <van-cell title="落叶的位置" value="已关注" />
            <van-cell title="落叶的位置" value="已关注" />
            <van-cell title="落叶的位置" value="已关注" />
            <van-cell title="落叶的位置" value="已关注" />
            <van-cell title="落叶的位置" value="已关注" /> -->
        </van-cell-group>
        <div class="empty" v-show="!flat">
            <van-empty description="暂无收藏" />
        </div>
    </div>
</template>
<script setup>
import { Cell, CellGroup, Empty } from "vant";
import { ref, defineComponent, onBeforeMount, reactive } from "vue";
import { selectCollectList, undateUserWeb } from "@/request/index";
import Myhead from "../../components/Myhead.vue";
import { useRouter } from "vue-router";
const router = useRouter();
defineComponent({
    Myhead,
});
let flat = ref(true);
let collectList = reactive({ list: [] });
let user_id = localStorage.getItem("token");
onBeforeMount(() => {
    selectCollectList({ user_id, comment_db: "comment" }).then((data) => {
        console.log(data);
        collectList.list = data.rows;
        if (collectList.list.length == 0) {
            flat = false;
        }
    });
});
const pathGo = (x) => {
    // console.log(x);
    let { user_id, comment_id, comment_db, digest } = x;
    // console.log(user_id, comment_id, comment_db, digest);
    router.push({ path: "/newsDetail", query: { id: comment_id } });

    undateUserWeb({ user_id, comment_id, comment_db, digest }).then((data) => {
        console.log("undateUserWeb", data);
    });
};
let title = ref("关注");
</script>
<style>
.van-nav-bar .van-icon,
.van-nav-bar__text {
    color: #576574;
}
.empty {
    margin-top: 100px;
}
</style>
